
const state = {
  type: null,
  basicForm: {
    name: '基础配置',
    status: false,
    errMsg: [],
    data: {
      name: '', // 业务名称
      businessType: '', // 业务类型：存于数据字典，保存中文
      dateSystemIds: [], // 数据系统 后台返回为 String: 1,2,3 , 前台保存为数组
      businessLevel: null, // 业务级别：1=总部级 2=区域级 3=项目级
      businessKpiParams: [], // 考核指标
      associatedBusinessKpiParams: [] // 关联指标
    }
  },
  businessForm: {
    name: '业务配置',
    status: false,
    errMsg: [],
    data: []
  },
  linkageForm: {
    name: '联动配置',
    status: false,
    errMsg: [],
    data: {}
  },
  reportForm: {
    name: '数据报告',
    status: false,
    errMsg: [],
    data: {}
  }
}
const mutations = {
  SET_BASIC_FORM: (state, payload) => {
    state.basicForm = { ...state.basicForm, ...payload }
  },
  SET_BUSINESS_FORM: (state, payload) => {
    state.businessForm = { ...state.businessForm, ...payload }
  },
  SET_LINKAGE_FORM: (state, payload) => {
    state.linkageForm = { ...state.linkageForm, ...payload }
  },
  SET_REPORT_FORM: (state, payload) => {
    state.reportForm = { ...state.reportForm, ...payload }
  }
}
const actions = {
  setBasicFormData({ commit }, payload) {
    commit('SET_BASIC_FORM', payload)
  },
  setBusinessFormData({ commit }, payload) {
    commit('SET_BUSINESS_FORM', payload)
  },
  setLinkageFormData({ commit }, payload) {
    commit('SET_LINKAGE_FORM', payload)
  },
  setReportFormData({ commit }, payload) {
    commit('SET_REPORT_FORM', payload)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
